package com.zeroup.auto.assists.step;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Path;

import androidx.annotation.NonNull;


import com.ven.assists.Assists;
import com.ven.assists.stepper.StepCollector;
import com.ven.assists.stepper.StepImpl;
import com.ven.assists.stepper.StepManager;

import kotlin.Unit;

public class WxStep extends StepImpl {
    @Override
    public void onImpl(@NonNull StepCollector stepCollector) {
        stepCollector.next(1,false,(i,c)->{
//            Intent intent = new Intent();
//            intent.addCategory(Intent.CATEGORY_LAUNCHER);
//            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            ComponentName component = ComponentName.createRelative("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
//            intent.setComponent(component);
//
//            assert Assists.getService() != null;
//            Assists.getService().startActivity(intent);
            PackageManager packageManager = Assists.getService().getPackageManager();
            Intent intent = packageManager.getLaunchIntentForPackage("com.ss.android.ugc.aweme");
            assert Assists.getService() != null;
            Assists.getService().startActivity(intent);
            StepManager.INSTANCE.execute(WxStep.class, 2,10000,null,false);
            return Unit.INSTANCE;
        }).next(2,false,(i,c)->{
              for (int a=0;a<=10;a++){
                  Path mPath=new Path();//线性的path代表手势路径,点代表按下,封闭的没用
                  mPath.moveTo(500, 1000);
                  mPath.lineTo(500, 400);
//                  Assists.gesture(mPath,0,300);
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException e) {
                      throw new RuntimeException(e);
                  }
              }
//            List<AccessibilityNodeInfo> infoList = Assists.INSTANCE.findById("com.tencent.mm:id/nvt");
//            if(infoList.isEmpty()){
//                return Unit.INSTANCE;
//            }
//            System.out.println("======>"+infoList.size());
//            infoList.forEach(a->{
//                List<AccessibilityNodeInfo> infoList1 = a.findAccessibilityNodeInfosByText("发现");
//                System.out.println("------------->"+infoList1.size());
////                Rect rect = new Rect();
////                a.getBoundsInScreen(rect);
//                if (!infoList1.isEmpty()) {
//                    a.performAction(AccessibilityNodeInfo.ACTION_CLICK);
//                }
//
////                UIOperate.INSTANCE.clickScreen(rect.centerX(),rect.centerY(),1000);
//            });

            return Unit.INSTANCE;
        });


    }
}
